/**
 * by samsun
 */
var domain = {
	id : 'domain-panel',
	title : '业务对象视图',
	layout : 'border',
	 closable:true,
	defaults : {
	
		bodyStyle : 'padding:15px'
	},
	items : [{
		
		title:'详细属性信息',
		region:'south',
		height:200,
		collapsible : true,
		border:false,
		contentEl:'domainDetail'
			          },
	         {
	    tbar: [{xtype:'button',width:50,text:'返回',iconCls: 'return',handler:returnToDomainList}],
		region : 'center',
		autoScroll:true,
		border : false,
		contentEl : 'domainCanvas'
	} ]
};

function returnToDomainList(){
	
	  Ext.getCmp('content-panel').layout.setActiveItem('domain-list-panel');
	  showDomainList();
}

function showModelContent(cid,text) {
	    Ext.getDom('domainDetail').innerHTML = "";
		var attributeStore = new Ext.data.Store({
		proxy : new Ext.data.HttpProxy({
			url : 'showDomainModelAttribute.action?method=showDomainModelAttribute',
			method : 'post'
			
		}),
		reader : new Ext.data.JsonReader({
			root : "Domainmodelattr",
			totalProperty : "totalAttribute",
			id:"id"
	    }, [ {
			name : 'id'
		}, {
			name : 'enName'
		},{
			name : 'cnName'
		},{
			name : 'description'
		},{
			name : 'cnType'
		}, {
			name : 'enType'
		}, {
			name : 'typeId'
		}, {
			name : 'minValue'
		}, {
			name : 'maxValue'
		}, {
			name : 'readOnly'
		}, {
			name : 'staticstate'
		}, {
			name : 'uni'
		}, {
			name : 'collectionType'
		}, {
			name : 'defaultValue'
		},{
			name : 'domainModelid'
		}])
	});
	
	
	
	attributeStore.load({
		params : {
			cid : cid
		},
		callback: function(r, options, success) { 
		if (success == false) {  
		alert("加载数据失败，无对应数据或者系统出现异常！"); 
		}else{ 
			
			var cm=new Ext.grid.ColumnModel([
				         						new Ext.grid.RowNumberer(),
				         						{header:'编号',dataIndex:'id'},
				         						{header:'名称(中文)',dataIndex:'cnName'},
				         						{header:'名称(英文)',dataIndex:'enName'},
				         						{header:'类型名称',dataIndex:'cnType'},
				         						{header:'最小值',dataIndex:'minValue'},
				         						{header:'最大值',dataIndex:'maxValue'},
				         						{header:'操作性',dataIndex:'readOnly'},
				         						{header:'唯一性',dataIndex:'uni'},
				         						{header:'集合类型',dataIndex:'collectionType'},
				         						{header:'缺省值',dataIndex:'defaultValue'},
				         						{header:'备注',dataIndex:'description'}
				         						
				         						
				         					]);
				         				var grid=new Ext.grid.GridPanel({
				         						renderTo:'domainDetail',
				         						 viewConfig: {
				         				            forceFit:true
				         				        },
				         						layout:'fit',
				         						stripeRows: true,
				         						autoHeight:true,
				         						loadMask:true,
				         						store:attributeStore,
				         						cm:cm
				         					});
			var stateStore = new Ext.data.Store({
				proxy : new Ext.data.HttpProxy({
					url : 'showDomainModelState.action?method=showDomainModelState',
					method : 'post'
				}),
				reader : new Ext.data.JsonReader({
					root : "Domainmodelstate",
					totalProperty : "totalState",
					id:"id"
			    }, [ {
					name : 'id'
				}, {
					name : 'enName'
				},{
					name : 'cnName'
				},{
					name : 'description'
				},{
					name : 'domainModelid'
				}])
			});
			stateStore.load({ 
				params : {
					cid : cid
				},
				callback: function(r, options, success) { 
				if (success == false) {  
				alert("加载数据失败，无对应数据或者系统出现异常！"); 
				}else{ 
					var canvas=document.getElementById('domainCanvas');
					var ctx=canvas.getContext('2d');
					drawDomainModel(300,100,ctx,attributeStore,stateStore,text);

				} 
				} 
				}); 
		} 
		} 
		}); 
	
	
	
}

     